{extend name="public/base" /}
{block name="container"}
<div class="panel panel-default">
    <div class="panel-heading">
      <h4 class="panel-title">添加店铺</h4>
  </div>
  <div class="panel-body panel-body-nopadding">

    <form class="form-horizontal form-bordered" id="submitForm" action="" method="post" >
        <div class="form-group">
            <label class="col-sm-3 control-label"><span>*</span>店铺名称：</label>
            <div class="col-sm-6">
                <input type="text" class="form-control" placeholder="店铺名称" name="title" value="{$data.title ?? ''}"  required>
            </div>
        </div>
        <div class="form-group">
          <label class="col-sm-3 control-label">所在地区：</label>
          <div class="col-sm-2">
            <select class="form-control" name="prov" onchange="getRegion(this.value,1)" required>
                    <option value="-1"> --请选择省-- </option>
                    {volist name="prov_data" id="prov_vo"}
                          <option value="{$prov_vo.code}">{$prov_vo.name} </option>
                    {/volist}
            </select>
          </div>
          <div class="col-sm-2">
            <select class="form-control" name="city" id="city" onchange="getRegion(this.value,2)" required>
                    <option value=""> --请选择市-- </option>
            </select>
          </div>
          <div class="col-sm-2">
            <select class="form-control" name="area" id="area" required>
                    <option value=""> --请选择区-- </option>
            </select>
          </div>
        </div>
        <div class="form-group">
        <label class="col-sm-3 control-label">详细地址：</label>
        <div class="col-sm-6">
            <input type="text" class="form-control" placeholder="详细地址" name="address" value="{$data.address ?? ''}"  required>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span>*</span>状态：</label>
        <div class="col-sm-6 wh-inline">
            <div class="rdio rdio-primary">
           
                <input type="radio" name="status" id="status-1" value="1" required>
                <label for="status-1">启用</label>
                <input type="radio" name="status" id="status-0" value="0" required >
                <label for="status-0">禁用</label>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">排序：</label>
        <div class="col-sm-6">
            <input type="number" class="form-control" placeholder="排序" name="orderid" value="{$data.orderid ?? ''}"  required>
        </div>
    </div>
    <div class="panel-footer">
       <div class="row">
          <div class="col-sm-6 col-sm-offset-3">
            <input type="hidden" name="id" value="{$data.id ?? ''}">
            <button type="submit" class="btn btn-primary">提交</button>
            <button type="button" class="btn btn-default" onclick="javascript:history.back(-1);">返回</button>
        </div>
    </div>
</div><!-- panel-footer -->

</form>

</div><!-- panel-body -->
{/block}
{block name="js"}
<script>
    function getRegion(val,level)
    {
      var $city = $("#city");
      var $area = $("#area");
      $.post('{:url('index/common/getRegion')}', { pcode: val,level:level}, function(data) {
               var dataObj=eval("("+data+")");//转换为json对象   
               if(dataObj['code']==1){
                if(level=='1'){
                    $.each(dataObj['list'], function(i, item) {
                      $city.append('<option value="'+item['code']+'">'+item['name']+'</option>');
                  });
                }else{
                    $.each(dataObj['list'], function(i, item) {
                      $area.append('<option value="'+item['code']+'">'+item['name']+'</option>');
                  });
                }
            }
        });
  }
</script>
{/block}